<template>
	<view class="conter">
		<header-box :title="title"></header-box>
		
		<view class="conter-text">
			<view class="bgc">
				<view class="box-btn">
					<view class="" style="margin-bottom: 30rpx;">
						单位名称
					</view>
					<view class="">
						<input type="text" v-model="name" placeholder="散客" placeholder-style="font-size: 28rpx"/>
					</view>
				</view>
				<view class="box-btn">
					<view class="" style="margin-bottom: 30rpx;">
						联系电话
					</view>
					<view class="">
						<input type="number" maxlength="11" v-model="phone" placeholder="请输入联系电话" placeholder-style="font-size: 28rpx"/>
					</view>
				</view>
				<view class="box-btn">
					<view class="" style="margin-bottom: 30rpx;">
						备注
					</view>
					<view class="">
						<input type="text" v-model="memo" placeholder="请填写备注" placeholder-style="font-size: 28rpx"/>
					</view>
				</view>
			</view>
		</view>
		
		<view class="add bg-gradual-green" @click="addName">
			保存
		</view>
	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'
	
	export default {
		components: {
			headerBox
		},
		data() {
			return {
				title: '添加资料',
				name: '',
				memo: '',
				phone: '',
			}
		},
		onLoad() {
			// this.stockList()
		},
		methods: {
			
			async stockList() {
				// const res = await this.$u.post("api/Company/add?name=" +  );
				// this.textList = res.data
				// this.value = res.data[0].id
				// this.total = res.data.length
				// console.log(res, '444444444')
			},
			
			async addName() {
				if (this.name == '' || this.phone == '' || this.memo == '') return this.$tools.msg('内容不能未空')
				console.log(this.name,this.phone,this.memo, 2222)
				const res = await this.$u.post("api/jinxiao.Company/add?name=" + this.name + "&phone=" + this.phone + "&memo=" + this.memo );
				if(res.code !== 1) return this.$tools.msg(res.msg)
				this.$tools.msg(res.msg)
				this.name = ''
				this.phone = ''
				this.memo = ''
				uni.navigateBack({
				    delta: 1
				})
			}
		}
	}
	
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100%;
		position: relative;
	}
	
	.conter-text {
		padding: 30rpx;
		
		.bgc {
			width: 100%;
			height: 500rpx;
			padding: 0 30rpx;
			border-radius: 10rpx;
			background-color: #FFFFFF;
			
			.box-btn {
				width: 100%;
				height: 144rpx;
				font-size: 30rpx;
				padding: 20rpx 0;
				border-bottom: 1rpx solid #F0F0F0;
			}
		}
	}
	
	.add {
		position: absolute;
		bottom: 30rpx;
		left: 50%;
		width: 90%;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 45rpx;
		transform: translateX(-50%);
		text-align: center;
		color: #FFFFFF;
		font-size: 32rpx;
	}
</style>
